#ifndef CSINGLETON_H
#define CSINGLETON_H
#include "stdio.h"
template <class Singleton>
class CSingleton
{
public:
	static Singleton* GetInstance()
	{
		if (!s_pInstance)
		{
			s_pInstance=new Singleton();
		}
		return s_pInstance;
	}
protected:
	static Singleton* s_pInstance;
};

template<class Singleton> Singleton* CSingleton<Singleton>::s_pInstance=0;

template <class AbsSingleton>
class CAbsSingleton
{
public:
	static AbsSingleton* GetInstance()
	{
		return s_pInstance;
	}
protected:
	static AbsSingleton* s_pInstance;
	void SetInstance(AbsSingleton* value)
	{
		if (!s_pInstance)
		{
			s_pInstance=value;
		} 
		else
		{
			printf("Singleton instance has been set before");
		}
	}
};

template<class AbsSingleton> AbsSingleton* CAbsSingleton<AbsSingleton>::s_pInstance=0;
#endif